package com.wujin.consumer.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import com.wujin.provider.dubbo.provider.DemoService;
import com.wujin.provider.model.User;
import com.wujin.provider.model.UserBean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Wu Jin
 * @create 2018-04-04 上午 9:25
 */
@RestController
public class MainController {

    @Reference(url = "dubbo://127.0.0.1:20880")
    private DemoService demoService;

    @RequestMapping("/sayHello")
    public String sayHello(@RequestParam String name) {
        return demoService.sayHello(name);
    }

    @RequestMapping("/user")
    public List<User> list() {
        return demoService.list();
    }

    @RequestMapping("/user2")
    public PageInfo<UserBean> list2(@RequestParam(required = false, defaultValue = "1") int num, @RequestParam(required = false, defaultValue = "3") int size) {
        return demoService.list2(num, size);
    }

}